/* TCSS 590A - Cybernetics and Systems
 * Group Project - Modeling
 * By Barry Jones, Naren Meadem, Michael Pitts, Yuan Tao
 * Fall 2012, University of Washington, Tacoma
 */

package model.delayed;


/**
 * An investment account deals with long term investments
 * Always negative
 * @author Naren Meadem
 * @version Dec 1, 2012
 */


public class LongtermReturnInvestment implements Investments
{
	
	
public long getLongTermValue;
	
	//Let the function know current iteration so that we can get value Depreciated
	
	
	
	public long DepricatedValue;
	private long PendingAmount;

	
	public long TotalAmountPayable ;
	
	public long DownPayment ;
	
	public long PendingAmountPayable(final long the_time){ return PendingAmount;}
	
	public long ReturnOnInvestmet;
	
	public int ReturnOnInvestmentCycle;
	
	public long EMI;
	
	public int InvestmentPeriod;
	
	public double myrate;
	
	public long my_time_emi;
	
	
	public long delay_in_return;

	public LongtermReturnInvestment(final long total_amount, final long the_EMI, final long emi_time,
			final int time_Period, final long get_LongTermValue, final long Down_Payment,final long Return_OnInvestmet, final int Return_OnInvestmentCycle, final double my_rate, final long the_delay_in_return )
	{
		getLongTermValue = get_LongTermValue;
		TotalAmountPayable = total_amount;
		DownPayment = Down_Payment;
		ReturnOnInvestmet = Return_OnInvestmet;
		ReturnOnInvestmentCycle = Return_OnInvestmentCycle;
		EMI = the_EMI;
		InvestmentPeriod = time_Period;
		PendingAmount = -(TotalAmountPayable-DownPayment);
		myrate = my_rate;
		my_time_emi = emi_time;
		delay_in_return = the_delay_in_return;
	}
	
	//DepricatedValue = (long)((TotalAmountPayable+PendingAmount) * 0.8);
	
	public long getLongTermValue () {return getLongTermValue;}
	
	public long getaccumulatedValue () {return TotalAmountPayable + PendingAmount;}
	
	public long TotalAmountPayable () {return TotalAmountPayable;}
	
	public long DownPayment () {return DownPayment;}
	
	public long ReturnOnInvestmet () {return ReturnOnInvestmet;}

	public int ReturnOnInvestmentCycle () {return ReturnOnInvestmentCycle;}
	
	public long EMI () {return EMI;}
	
	
	public long delay_in_return() {return delay_in_return;}
	
	public int InvestmentPeriod () {return InvestmentPeriod;}
	
	public long EMI_time () {return my_time_emi;}
	
	public long getValue() {return PendingAmount;}
	
	public void changeValue(final long the_value) {PendingAmount += the_value;}
	
	public Event deposit(final long the_value, final long the_time) 
	{
		return new Event(the_value, the_time, this);
	}
	public Event withdraw(final long the_value, final long the_time)
	{
		
		//not sure wht to keep as we cannot withdraw from a loan account
		
		if(-(PendingAmount-the_value)  >= TotalAmountPayable)
		return null;
		else 
		{
			//this.changeValue(PendingAmount= PendingAmount-the_value);
			return new Event(the_value, the_time, this);
		}
	}
	
	public long getDepreciatedValue () {return (long)((TotalAmountPayable+PendingAmount) * 0.8);}
	
	public double getRate() {return myrate;}
	
	@Override public boolean inLegalState()
	{
		return getValue() <= 0;
	}
	
	
	//want to update the ROI to the main account
	
	//Inputs are the ROI's for this investment and outputs are the EMI
	
	public void ROI (final long the_time) { if (the_time% ReturnOnInvestmentCycle ==0) { this.deposit(ReturnOnInvestmet, the_time);} }
	
	public void addInterest()
	{
	
	     
         
	}
	
	
	// method to update this account
	
   // How the main account will get updated
	
	
	
}
